package com.lms.admin.base.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lms.admin.base.service.ISysRoleService;
import com.lms.common.entity.SysRole;
import com.lms.common.pure.query.QueryParams;
import com.lms.common.web.controller.BaseController;
import com.lms.common.web.utils.CheckEntityResult;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/sysRole")
@PreAuthorize("hasRole('ADMIN')")
@Tag(name="角色相关请求")
public class SysRoleController extends BaseController<ISysRoleService, SysRole> {
    @Override
    @PostMapping("/query")
    public IPage<?> query(@Parameter(description = "查询参数") @RequestBody QueryParams<Map<String, Object>> queryParams) {
        return super.query(queryParams);
    }

    @Override
    @GetMapping("/get/{id}")
    public Object get(@PathVariable("id") Serializable id) {
        return super.get(id);
    }

    @Override
    @PostMapping("/getByFilter")
    public Object getByFilter(@Parameter(description = "查询参数") @RequestBody Map<String, Object> queryParams) {
        return super.getByFilter(queryParams);
    }

    @Override
    @PostMapping("/save")
    public SysRole save(@Parameter(description = "保存的对象") @RequestBody Map<String, Object> entity) {
        return super.save(entity);
    }

    @PostMapping("/beforeSaveCheck")
    public CheckEntityResult beforeSaveCheck(@Parameter(description = "需要校验的保存对象") @RequestBody SysRole entity) {
        return super.beforeSaveCheck(entity);
    }

    @Override
    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") Serializable id) {
        super.delete(id);
    }

    @Override
    @PostMapping("/deleteBatch")
    public void deleteBatch(@RequestBody List<Serializable> ids) {
        super.deleteBatch(ids);
    }

    @GetMapping("/toggleStatus/{id}")
    public void toggleStatus(@PathVariable("id") Long id) {
        this.baseService.toggleStatus(id);
    }


}
